(function() {
		/**获得当前的年月日**/
		var current_nian=new Date();
		var nian=current_nian.getFullYear();
	/***循环1900到现在的年份***/
	for(var i=nian;i>=1900;i--){
		var nian =$("#nian");
		var li="<li>"+i+"</li>";
		nian.append(li);
	}
var icon_nan = $(".icon-nan"),
	icon_nv = $(".icon-nv"),
	cus_select_sex = $(".cus_select_sex input");
exchange_sex = $(".exchange_sex");
exchange_sex.on("click", function() {
	if(cus_select_sex[0].value == "男") {
		cus_select_sex.val("女");
		icon_nan.eq(1).css("display", "none");
		icon_nv.css("display", "block");
	} else {
		cus_select_sex.val("男");
		icon_nan.eq(1).css("display", "block");
		icon_nv.css("display", "none");
	}
})
//省市 区三级联动
$(function() {
	var pro = $("#pro"),
			city_name = $("#city"),
			direct_id = $("#direct"),
			xuanzechengshi=$("#xuanzechengshi"),
			xuanzediqu=$("#xuanzediqu");
			/*点击空白的时候加上请选择地区和选择城市*/
			var li_city="<li>请选择城市</li>";
			city_name.append(li_city);
			var li_direct="<li>请选择地区</li>";
			direct_id.append(li_direct);
		$.each(province, function(k, p) {
			var li = "<li data-id='" + p.ProID + "'>" + p.ProName + "</li>";
			pro.append(li);
		});
		$("#pro li").on("click", function() {
			$("#city li").remove();
			$("#direct li").remove();
			/*清楚城市以及地区的值**/
			xuanzechengshi.val("");
			xuanzediqu.val("");
			var pro_val = $(this).data("id");
			$.each(city, function(k, p) {
				if(p.ProID == pro_val) {
					var li = "<li data-id='" + p.CityID + "'>" + p.CityName + "</li>";
					city_name.append(li);
				}
			});
		});
		$("#city").on("click", "li", function() {
			$("#direct li").remove();
			xuanzediqu.val("");
			/*点击请选择城市的时候加上请选择地区*/
			var li_direct="<li>请选择地区</li>";
			direct_id.append(li_direct);
			var city_val = $(this).data("id");
			$.each(District, function(k, p) {
				if(p.CityID == city_val) {
					var li = "<li data-id='" + p.ID + "'>" + p.DisName + "</li>";
					direct_id.append(li);
				}
			});
		})
});
$(function(){
	$("#hang_select").on("click",function() {
		var hangye_id=$("#hangye_id"),
			hy=$("#hy");
		$.each(hangye, function(k, p) {
					var li = "<li>" + p.name + "</li>";
					hy.append(li);

		});
	})
});
/**上传头像部分**/
var input_file=$("input[type=file]"),
	img_file=$(".jibxx_headleft img"),
	zhezhao_content=$("#zhezhaocontent");
input_file.on("change",function(){
		var file = this.files[0];
			if(!/image\/\w+/.test(file.type)){
				zhezhao.css("display","block");
				zhezhao_content.text("请传入有效图片");
			}else if(file.fileSize>=5242880){
				zhezhao.css("display","block");
				zhezhao_content.text("上传图片要小于5M");
			}
            if(window.FileReader) {  
                var fr = new FileReader();  
                fr.onloadend = function(e) {  
                    img_file[0].src = e.target.result;  
                };  
                fr.readAsDataURL(file);  
//              location.href="ji_bxx.html";
            }  
})
var nc_input=$(".jibxx_nicheng input"),//获取昵称的值
	nc_tishi=$(".jibxx_nicheng  a");
	nc_input.on("change",function(){
		var nc_val=$(".jibxx_nicheng input").val(),
			r_2=/^[_]{4,32}$/;
		if(r_2.test(nc_val)){
			nc_tishi.css("opacity","1");
		}else if(nc_val.length<=4||nc_val.length>=32||isNaN(Number(nc_val))==false){
			nc_tishi.css("opacity","1");
		}else{
			nc_tishi.css("opacity","0");
		}
	})	
	/*******保存按钮********/
	var btn_save=$("#baocun"),
		zhezhao=$(".jibxx_mask");
	btn_save.on("click",function(){
		var save_val=nc_tishi[0].style.opacity;
		if(save_val==1||nc_input[0].value==""){
			zhezhao.css("display","block");
		}
	})
	/*点击xx遮罩层消失**/
	var zhezhao_xx =$("#o5_dele");
	zhezhao_xx.on("click",function(){
		zhezhao.css("display","none");
	})




})();